#include<iostream>
using namespace std;



bool binary_search(int arr[] ,int n,int target)
{
  int k=0;
  int l=0;
  int r=n;
  int mid;
  while (r>l)
  {
      mid = (r+l)/2;
      k++;
      if(arr[mid]==target)
      {
          cout<<"查询次数： "<<k<<endl;
          return true;
      }
      else
      {
          if(arr[mid]>target)
              r = mid;
          else
              l=mid+1;
       }
  }
  return false;
}

int main()
{
    int a[100];
    int n=100;
    int target=33;
    bool flag;
    for(int i=0;i<100;i++)
    {
        a[i]=i;
    }

    flag = binary_search(a,n,target);
    cout<< flag<<endl;
    return 0;
}


